#include "CalculatorMainForm.h"

using namespace Osp::Base;
using namespace Osp::Ui;
using namespace Osp::Ui::Controls;

CalculatorMainForm::CalculatorMainForm(void)
{
}

CalculatorMainForm::~CalculatorMainForm(void)
{
}

bool
CalculatorMainForm::Initialize()
{
	// Construct an XML form
	Construct(L"IDF_CALCULATORMAINFORM");

	return true;
}

result
CalculatorMainForm::OnInitializing(void)
{
	result r = E_SUCCESS;

	// TODO: Add your initialization code here

	// Get a button via resource ID
	__pButtonOk = static_cast<Button *>(GetControl(L"IDC_BUTTON_OK"));
	if (__pButtonOk != null)
	{
		__pButtonOk->SetActionId(ID_BUTTON_OK);
		__pButtonOk->AddActionEventListener(*this);
	}

	editArea = static_cast<EditArea *>(GetControl(L"IDC_BUTTON_OK"));

	return r;
}

result
CalculatorMainForm::OnTerminating(void)
{
	result r = E_SUCCESS;

	// TODO: Add your termination code here

	return r;
}

void
CalculatorMainForm::OnActionPerformed(const Osp::Ui::Control& source, int actionId)
{
	switch(actionId)
	{
	case ID_BUTTON_OK:
		{
			AppLog("OK Button is clicked! \n");
			StringCalculator sc;
			//__pButtonOk->SetText(sc.subtract("11", "11"));
			RequestRedraw(true);
		}
		break;
	default:
		break;
	}
}


